Change in openvpn[master]: tapctl: make output of 'list' and 'create' commands more verbose
A message that is not in the archive (sent off-list or not yet received): gerrit.1762950770000.Iac6bcf8b5434aa414e86cb4b9742e7dd591dc796@...2715...
Attention is currently required from: plaisthos.
Hello plaisthos,
I'd like you to do a code review.
Please visit
http://gerrit.openvpn.net/c/openvpn/+/1372?usp=email
to review the following change.
Change subject: tapctl: make output of 'list' and 'create' commands more verbose
......................................................................
tapctl: make output of 'list' and 'create' commands more verbose
Print adapter GUID, name and hwid.
---
M src/tapctl/main.c
1 file changed, 36 insertions(+), 20 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/72/1372/1
src/tapctl/main.c +36 -20
@@ -80,7 +80,8 @@L"\n" L"Output:\n" L"\n" -L"This command prints newly created VPN network adapter's GUID to stdout. \n" +L"This command prints newly created VPN network adapter's GUID, name and \n" +L"hardware ID to stdout. \n" ; static const WCHAR usage_message_list[] =
@@ -99,7 +100,7 @@L"\n" L"Output:\n" L"\n" -L"This command prints all VPN network adapters to stdout. \n" +L"This command prints VPN network adapter GUID, name and hardware ID to stdout. \n" ; static const WCHAR usage_message_delete[] =
@@ -211,10 +212,12 @@LPCWSTR szName =NULL ;LPCWSTR szHwId =L"root\\" _L(TAP_WIN_COMPONENT_ID );struct tap_adapter_node *adapter_list =NULL ; -LPWSTR adapter_name =NULL ; +LPWSTR rename_name =NULL ; +LPWSTR final_name =NULL ;LPOLESTR adapter_id =NULL ;GUID guidAdapter;int result =1 ; +BOOL delete_created_adapter = FALSE;for (int i =2 ; i < argc; i++) {
@@ -247,45 +250,57 @@if (dwResult !=ERROR_SUCCESS ) {fwprintf (stderr,L"Enumerating adapters failed (error 0x%x).\n" , dwResult); -tap_delete_adapter (NULL , &guidAdapter, bRebootRequired); -return result; + delete_created_adapter = TRUE; + goto cleanup; } - adapter_name = szName ?wcsdup (szName) :get_unique_adapter_name (szHwId, adapter_list); -if (adapter_name) + rename_name = szName ?wcsdup (szName) :get_unique_adapter_name (szHwId, adapter_list); +if (rename_name) { -if (szName && !is_adapter_name_available (adapter_name, adapter_list, TRUE)) +if (szName && !is_adapter_name_available (rename_name, adapter_list, TRUE)) { -tap_delete_adapter (NULL , &guidAdapter, bRebootRequired); + delete_created_adapter = TRUE; goto cleanup; } - dwResult =tap_set_adapter_name (&guidAdapter, adapter_name, FALSE); -if (dwResult !=ERROR_SUCCESS ) + dwResult =tap_set_adapter_name (&guidAdapter, rename_name, FALSE); +if (dwResult ==ERROR_SUCCESS ) + { + final_name = rename_name; + rename_name =NULL ; + } +else {StringFromIID ((REFIID )&guidAdapter, &adapter_id);fwprintf (stderr,L"Renaming TUN/TAP adapter %ls" L" to \"%ls\" failed (error 0x%x).\n" , - adapter_id, adapter_name, dwResult); + adapter_id, rename_name, dwResult);CoTaskMemFree (adapter_id); - goto cleanup; } } result =0 ; cleanup: -free (adapter_name);tap_free_adapter_list (adapter_list); +free (rename_name); -if (result ==0 ) +if (result ==0 && final_name) {StringFromIID ((REFIID )&guidAdapter, &adapter_id); -fwprintf (stdout,L"%ls\n" , adapter_id); +const WCHAR *name_to_print = final_name ? final_name :L"" ; +fwprintf (stdout,L"%ls\t%ls\t%ls\n" , adapter_id, name_to_print, szHwId ? szHwId :L"" );CoTaskMemFree (adapter_id); } +free (final_name); + +if (result !=0 && delete_created_adapter) + { +tap_delete_adapter (NULL , &guidAdapter, bRebootRequired); + } +return result; }
@@ -327,10 +342,11 @@ {LPOLESTR adapter_id =NULL ;StringFromIID ((REFIID )&adapter->guid, &adapter_id); -fwprintf (stdout, -L"%ls\t%" -L"ls\n" , - adapter_id, adapter->szName); +const WCHAR *name = adapter->szName ? adapter->szName :L"" ; +const WCHAR *hwid = (adapter->szzHardwareIDs && adapter->szzHardwareIDs[0 ]) + ? adapter->szzHardwareIDs + :L"" ; +fwprintf (stdout,L"%ls\t%ls\t%ls\n" , adapter_id, name, hwid);CoTaskMemFree (adapter_id); }
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1372?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Iac6bcf8b5434aa414e86cb4b9742e7dd591dc796
Gerrit-Change-Number: 1372
Gerrit-PatchSet: 1
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Attention is currently required from: plaisthos, stipa.
cron2 has posted comments on this change by stipa. ( http://gerrit.openvpn.net/c/openvpn/+/1372?usp=email )
Change subject: tapctl: make output of 'list' and 'create' commands more verbose
......................................................................
Patch Set 1: Code-Review-1
(1 comment)
File src/tapctl/main.c:
http://gerrit.openvpn.net/c/openvpn/+/1372/comment/e8c04fb5_f9261de4?usp=email :
PS1, Line 292: const WCHAR *name_to_print = final_name ? final_name : L"";
this looks a bit superfluous? This branch is only entered if (final_name)
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1372?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Iac6bcf8b5434aa414e86cb4b9742e7dd591dc796
Gerrit-Change-Number: 1372
Gerrit-PatchSet: 1
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: stipa <[email protected]...>
Gerrit-Comment-Date: Fri, 14 Nov 2025 21:25:38 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Attention is currently required from: cron2, plaisthos, stipa.
Hello cron2, plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/1372?usp=email
to look at the new patch set (#2).
The following approvals got outdated and were removed:
Code-Review-1 by cron2
Change subject: tapctl: make output of 'list' and 'create' commands more verbose
......................................................................
tapctl: make output of 'list' and 'create' commands more verbose
Print adapter GUID, name and hwid.
---
M src/tapctl/main.c
1 file changed, 35 insertions(+), 20 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/72/1372/2
src/tapctl/main.c +35 -20
@@ -80,7 +80,8 @@L"\n" L"Output:\n" L"\n" -L"This command prints newly created VPN network adapter's GUID to stdout. \n" +L"This command prints newly created VPN network adapter's GUID, name and \n" +L"hardware ID to stdout. \n" ; static const WCHAR usage_message_list[] =
@@ -99,7 +100,7 @@L"\n" L"Output:\n" L"\n" -L"This command prints all VPN network adapters to stdout. \n" +L"This command prints VPN network adapter GUID, name and hardware ID to stdout. \n" ; static const WCHAR usage_message_delete[] =
@@ -211,10 +212,12 @@LPCWSTR szName =NULL ;LPCWSTR szHwId =L"root\\" _L(TAP_WIN_COMPONENT_ID );struct tap_adapter_node *adapter_list =NULL ; -LPWSTR adapter_name =NULL ; +LPWSTR rename_name =NULL ; +LPWSTR final_name =NULL ;LPOLESTR adapter_id =NULL ;GUID guidAdapter;int result =1 ; +BOOL delete_created_adapter = FALSE;for (int i =2 ; i < argc; i++) {
@@ -247,45 +250,56 @@if (dwResult !=ERROR_SUCCESS ) {fwprintf (stderr,L"Enumerating adapters failed (error 0x%x).\n" , dwResult); -tap_delete_adapter (NULL , &guidAdapter, bRebootRequired); -return result; + delete_created_adapter = TRUE; + goto cleanup; } - adapter_name = szName ?wcsdup (szName) :get_unique_adapter_name (szHwId, adapter_list); -if (adapter_name) + rename_name = szName ?wcsdup (szName) :get_unique_adapter_name (szHwId, adapter_list); +if (rename_name) { -if (szName && !is_adapter_name_available (adapter_name, adapter_list, TRUE)) +if (szName && !is_adapter_name_available (rename_name, adapter_list, TRUE)) { -tap_delete_adapter (NULL , &guidAdapter, bRebootRequired); + delete_created_adapter = TRUE; goto cleanup; } - dwResult =tap_set_adapter_name (&guidAdapter, adapter_name, FALSE); -if (dwResult !=ERROR_SUCCESS ) + dwResult =tap_set_adapter_name (&guidAdapter, rename_name, FALSE); +if (dwResult ==ERROR_SUCCESS ) + { + final_name = rename_name; + rename_name =NULL ; + } +else {StringFromIID ((REFIID )&guidAdapter, &adapter_id);fwprintf (stderr,L"Renaming TUN/TAP adapter %ls" L" to \"%ls\" failed (error 0x%x).\n" , - adapter_id, adapter_name, dwResult); + adapter_id, rename_name, dwResult);CoTaskMemFree (adapter_id); - goto cleanup; } } result =0 ; cleanup: -free (adapter_name);tap_free_adapter_list (adapter_list); +free (rename_name); -if (result ==0 ) +if (result ==0 && final_name) {StringFromIID ((REFIID )&guidAdapter, &adapter_id); -fwprintf (stdout,L"%ls\n" , adapter_id); +fwprintf (stdout,L"%ls\t%ls\t%ls\n" , adapter_id, final_name, szHwId ? szHwId :L"" );CoTaskMemFree (adapter_id); } +free (final_name); + +if (result !=0 && delete_created_adapter) + { +tap_delete_adapter (NULL , &guidAdapter, bRebootRequired); + } +return result; }
@@ -327,10 +341,11 @@ {LPOLESTR adapter_id =NULL ;StringFromIID ((REFIID )&adapter->guid, &adapter_id); -fwprintf (stdout, -L"%ls\t%" -L"ls\n" , - adapter_id, adapter->szName); +const WCHAR *name = adapter->szName ? adapter->szName :L"" ; +const WCHAR *hwid = (adapter->szzHardwareIDs && adapter->szzHardwareIDs[0 ]) + ? adapter->szzHardwareIDs + :L"" ; +fwprintf (stdout,L"%ls\t%ls\t%ls\n" , adapter_id, name, hwid);CoTaskMemFree (adapter_id); }
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1372?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Iac6bcf8b5434aa414e86cb4b9742e7dd591dc796
Gerrit-Change-Number: 1372
Gerrit-PatchSet: 2
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: stipa <[email protected]...>
Attention is currently required from: cron2, plaisthos.
stipa has posted comments on this change by stipa. ( http://gerrit.openvpn.net/c/openvpn/+/1372?usp=email )
Change subject: tapctl: make output of 'list' and 'create' commands more verbose
......................................................................
Patch Set 2:
(2 comments)
Patchset:
PS2:
Fixed
File src/tapctl/main.c:
http://gerrit.openvpn.net/c/openvpn/+/1372/comment/6ccb1870_75142321?usp=email :
PS1, Line 292: const WCHAR *name_to_print = final_name ? final_name : L"";
Quoted 1 line
this looks a bit superfluous? This branch is only entered
if (final_name)
Done
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1372?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Iac6bcf8b5434aa414e86cb4b9742e7dd591dc796
Gerrit-Change-Number: 1372
Gerrit-PatchSet: 2
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Comment-Date: Sat, 15 Nov 2025 18:57:59 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: cron2 <[email protected]...>
Attention is currently required from: plaisthos, stipa.
cron2 has posted comments on this change by stipa. ( http://gerrit.openvpn.net/c/openvpn/+/1372?usp=email )
Change subject: tapctl: make output of 'list' and 'create' commands more verbose
......................................................................
Patch Set 2: Code-Review+2
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1372?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Iac6bcf8b5434aa414e86cb4b9742e7dd591dc796
Gerrit-Change-Number: 1372
Gerrit-PatchSet: 2
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: stipa <[email protected]...>
Gerrit-Comment-Date: Sun, 16 Nov 2025 11:32:14 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
PATCH v2 1/1 tapctl: make output of 'list' and 'create' commands more verbose
In reply to a message not in the archiveFrom: Lev Stipakov <[email protected]...>
Print adapter GUID, name and hwid.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1372
---
This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1372
This mail reflects revision 2 of this Change.
Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>
src/tapctl/main.c +35 -20
@@ -80,7 +80,8 @@L"\n" L"Output:\n" L"\n" -L"This command prints newly created VPN network adapter's GUID to stdout. \n" +L"This command prints newly created VPN network adapter's GUID, name and \n" +L"hardware ID to stdout. \n" ; static const WCHAR usage_message_list[] =
@@ -99,7 +100,7 @@L"\n" L"Output:\n" L"\n" -L"This command prints all VPN network adapters to stdout. \n" +L"This command prints VPN network adapter GUID, name and hardware ID to stdout. \n" ; static const WCHAR usage_message_delete[] =
@@ -211,10 +212,12 @@LPCWSTR szName =NULL ;LPCWSTR szHwId =L"root\\" _L(TAP_WIN_COMPONENT_ID );struct tap_adapter_node *adapter_list =NULL ; -LPWSTR adapter_name =NULL ; +LPWSTR rename_name =NULL ; +LPWSTR final_name =NULL ;LPOLESTR adapter_id =NULL ;GUID guidAdapter;int result =1 ; +BOOL delete_created_adapter = FALSE;for (int i =2 ; i < argc; i++) {
@@ -247,45 +250,56 @@if (dwResult !=ERROR_SUCCESS ) {fwprintf (stderr,L"Enumerating adapters failed (error 0x%x).\n" , dwResult); -tap_delete_adapter (NULL , &guidAdapter, bRebootRequired); -return result; + delete_created_adapter = TRUE; + goto cleanup; } - adapter_name = szName ?wcsdup (szName) :get_unique_adapter_name (szHwId, adapter_list); -if (adapter_name) + rename_name = szName ?wcsdup (szName) :get_unique_adapter_name (szHwId, adapter_list); +if (rename_name) { -if (szName && !is_adapter_name_available (adapter_name, adapter_list, TRUE)) +if (szName && !is_adapter_name_available (rename_name, adapter_list, TRUE)) { -tap_delete_adapter (NULL , &guidAdapter, bRebootRequired); + delete_created_adapter = TRUE; goto cleanup; } - dwResult =tap_set_adapter_name (&guidAdapter, adapter_name, FALSE); -if (dwResult !=ERROR_SUCCESS ) + dwResult =tap_set_adapter_name (&guidAdapter, rename_name, FALSE); +if (dwResult ==ERROR_SUCCESS ) + { + final_name = rename_name; + rename_name =NULL ; + } +else {StringFromIID ((REFIID )&guidAdapter, &adapter_id);fwprintf (stderr,L"Renaming TUN/TAP adapter %ls" L" to \"%ls\" failed (error 0x%x).\n" , - adapter_id, adapter_name, dwResult); + adapter_id, rename_name, dwResult);CoTaskMemFree (adapter_id); - goto cleanup; } } result =0 ; cleanup: -free (adapter_name);tap_free_adapter_list (adapter_list); +free (rename_name); -if (result ==0 ) +if (result ==0 && final_name) {StringFromIID ((REFIID )&guidAdapter, &adapter_id); -fwprintf (stdout,L"%ls\n" , adapter_id); +fwprintf (stdout,L"%ls\t%ls\t%ls\n" , adapter_id, final_name, szHwId ? szHwId :L"" );CoTaskMemFree (adapter_id); } +free (final_name); + +if (result !=0 && delete_created_adapter) + { +tap_delete_adapter (NULL , &guidAdapter, bRebootRequired); + } +return result; }
@@ -327,10 +341,11 @@ {LPOLESTR adapter_id =NULL ;StringFromIID ((REFIID )&adapter->guid, &adapter_id); -fwprintf (stdout, -L"%ls\t%" -L"ls\n" , - adapter_id, adapter->szName); +const WCHAR *name = adapter->szName ? adapter->szName :L"" ; +const WCHAR *hwid = (adapter->szzHardwareIDs && adapter->szzHardwareIDs[0 ]) + ? adapter->szzHardwareIDs + :L"" ; +fwprintf (stdout,L"%ls\t%ls\t%ls\n" , adapter_id, name, hwid);CoTaskMemFree (adapter_id); }
[Openvpn-devel] [PATCH applied] Re: tapctl: make output of 'list' and 'create' commands more verbose
Stared at the code (looks good), built a test binary on ubuntu 24.04/mingw, tested that (64 bit intel binary) on Win11 24H2/ARM, and everything works and does what it says on the lid.
Do I see more room for output improvement? Always :-) - but this is already improving things, so, ship it!
Your patch has been applied to the master branch.
commit c8f0e726f1d3d02d546d7eb3ef03eb7429c44272
Author: Lev Stipakov Date: Sun Nov 16 12:32:24 2025 +0100
tapctl: make output of 'list' and 'create' commands more verbose
Signed-off-by: Lev Stipakov <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1372
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg34451.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
cron2 has uploaded a new patch set (#3) to the change originally created by stipa. ( http://gerrit.openvpn.net/c/openvpn/+/1372?usp=email )
The following approvals got outdated and were removed:
Code-Review+2 by cron2
Change subject: tapctl: make output of 'list' and 'create' commands more verbose
......................................................................
tapctl: make output of 'list' and 'create' commands more verbose
Print adapter GUID, name and hwid.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1372
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg34451.html
---
M src/tapctl/main.c
1 file changed, 35 insertions(+), 20 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/72/1372/3
src/tapctl/main.c +35 -20
@@ -80,7 +80,8 @@L"\n" L"Output:\n" L"\n" -L"This command prints newly created VPN network adapter's GUID to stdout. \n" +L"This command prints newly created VPN network adapter's GUID, name and \n" +L"hardware ID to stdout. \n" ; static const WCHAR usage_message_list[] =
@@ -99,7 +100,7 @@L"\n" L"Output:\n" L"\n" -L"This command prints all VPN network adapters to stdout. \n" +L"This command prints VPN network adapter GUID, name and hardware ID to stdout. \n" ; static const WCHAR usage_message_delete[] =
@@ -211,10 +212,12 @@LPCWSTR szName =NULL ;LPCWSTR szHwId =L"root\\" _L(TAP_WIN_COMPONENT_ID );struct tap_adapter_node *adapter_list =NULL ; -LPWSTR adapter_name =NULL ; +LPWSTR rename_name =NULL ; +LPWSTR final_name =NULL ;LPOLESTR adapter_id =NULL ;GUID guidAdapter;int result =1 ; +BOOL delete_created_adapter = FALSE;for (int i =2 ; i < argc; i++) {
@@ -247,45 +250,56 @@if (dwResult !=ERROR_SUCCESS ) {fwprintf (stderr,L"Enumerating adapters failed (error 0x%x).\n" , dwResult); -tap_delete_adapter (NULL , &guidAdapter, bRebootRequired); -return result; + delete_created_adapter = TRUE; + goto cleanup; } - adapter_name = szName ?wcsdup (szName) :get_unique_adapter_name (szHwId, adapter_list); -if (adapter_name) + rename_name = szName ?wcsdup (szName) :get_unique_adapter_name (szHwId, adapter_list); +if (rename_name) { -if (szName && !is_adapter_name_available (adapter_name, adapter_list, TRUE)) +if (szName && !is_adapter_name_available (rename_name, adapter_list, TRUE)) { -tap_delete_adapter (NULL , &guidAdapter, bRebootRequired); + delete_created_adapter = TRUE; goto cleanup; } - dwResult =tap_set_adapter_name (&guidAdapter, adapter_name, FALSE); -if (dwResult !=ERROR_SUCCESS ) + dwResult =tap_set_adapter_name (&guidAdapter, rename_name, FALSE); +if (dwResult ==ERROR_SUCCESS ) + { + final_name = rename_name; + rename_name =NULL ; + } +else {StringFromIID ((REFIID )&guidAdapter, &adapter_id);fwprintf (stderr,L"Renaming TUN/TAP adapter %ls" L" to \"%ls\" failed (error 0x%x).\n" , - adapter_id, adapter_name, dwResult); + adapter_id, rename_name, dwResult);CoTaskMemFree (adapter_id); - goto cleanup; } } result =0 ; cleanup: -free (adapter_name);tap_free_adapter_list (adapter_list); +free (rename_name); -if (result ==0 ) +if (result ==0 && final_name) {StringFromIID ((REFIID )&guidAdapter, &adapter_id); -fwprintf (stdout,L"%ls\n" , adapter_id); +fwprintf (stdout,L"%ls\t%ls\t%ls\n" , adapter_id, final_name, szHwId ? szHwId :L"" );CoTaskMemFree (adapter_id); } +free (final_name); + +if (result !=0 && delete_created_adapter) + { +tap_delete_adapter (NULL , &guidAdapter, bRebootRequired); + } +return result; }
@@ -327,10 +341,11 @@ {LPOLESTR adapter_id =NULL ;StringFromIID ((REFIID )&adapter->guid, &adapter_id); -fwprintf (stdout, -L"%ls\t%" -L"ls\n" , - adapter_id, adapter->szName); +const WCHAR *name = adapter->szName ? adapter->szName :L"" ; +const WCHAR *hwid = (adapter->szzHardwareIDs && adapter->szzHardwareIDs[0 ]) + ? adapter->szzHardwareIDs + :L"" ; +fwprintf (stdout,L"%ls\t%ls\t%ls\n" , adapter_id, name, hwid);CoTaskMemFree (adapter_id); }
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1372?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Iac6bcf8b5434aa414e86cb4b9742e7dd591dc796
Gerrit-Change-Number: 1372
Gerrit-PatchSet: 3
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1372?usp=email )
Change subject: tapctl: make output of 'list' and 'create' commands more verbose
......................................................................
tapctl: make output of 'list' and 'create' commands more verbose
Print adapter GUID, name and hwid.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1372
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg34451.html
---
M src/tapctl/main.c
1 file changed, 35 insertions(+), 20 deletions(-)
src/tapctl/main.c +35 -20
@@ -80,7 +80,8 @@L"\n" L"Output:\n" L"\n" -L"This command prints newly created VPN network adapter's GUID to stdout. \n" +L"This command prints newly created VPN network adapter's GUID, name and \n" +L"hardware ID to stdout. \n" ; static const WCHAR usage_message_list[] =
@@ -99,7 +100,7 @@L"\n" L"Output:\n" L"\n" -L"This command prints all VPN network adapters to stdout. \n" +L"This command prints VPN network adapter GUID, name and hardware ID to stdout. \n" ; static const WCHAR usage_message_delete[] =
@@ -211,10 +212,12 @@LPCWSTR szName =NULL ;LPCWSTR szHwId =L"root\\" _L(TAP_WIN_COMPONENT_ID );struct tap_adapter_node *adapter_list =NULL ; -LPWSTR adapter_name =NULL ; +LPWSTR rename_name =NULL ; +LPWSTR final_name =NULL ;LPOLESTR adapter_id =NULL ;GUID guidAdapter;int result =1 ; +BOOL delete_created_adapter = FALSE;for (int i =2 ; i < argc; i++) {
@@ -247,45 +250,56 @@if (dwResult !=ERROR_SUCCESS ) {fwprintf (stderr,L"Enumerating adapters failed (error 0x%x).\n" , dwResult); -tap_delete_adapter (NULL , &guidAdapter, bRebootRequired); -return result; + delete_created_adapter = TRUE; + goto cleanup; } - adapter_name = szName ?wcsdup (szName) :get_unique_adapter_name (szHwId, adapter_list); -if (adapter_name) + rename_name = szName ?wcsdup (szName) :get_unique_adapter_name (szHwId, adapter_list); +if (rename_name) { -if (szName && !is_adapter_name_available (adapter_name, adapter_list, TRUE)) +if (szName && !is_adapter_name_available (rename_name, adapter_list, TRUE)) { -tap_delete_adapter (NULL , &guidAdapter, bRebootRequired); + delete_created_adapter = TRUE; goto cleanup; } - dwResult =tap_set_adapter_name (&guidAdapter, adapter_name, FALSE); -if (dwResult !=ERROR_SUCCESS ) + dwResult =tap_set_adapter_name (&guidAdapter, rename_name, FALSE); +if (dwResult ==ERROR_SUCCESS ) + { + final_name = rename_name; + rename_name =NULL ; + } +else {StringFromIID ((REFIID )&guidAdapter, &adapter_id);fwprintf (stderr,L"Renaming TUN/TAP adapter %ls" L" to \"%ls\" failed (error 0x%x).\n" , - adapter_id, adapter_name, dwResult); + adapter_id, rename_name, dwResult);CoTaskMemFree (adapter_id); - goto cleanup; } } result =0 ; cleanup: -free (adapter_name);tap_free_adapter_list (adapter_list); +free (rename_name); -if (result ==0 ) +if (result ==0 && final_name) {StringFromIID ((REFIID )&guidAdapter, &adapter_id); -fwprintf (stdout,L"%ls\n" , adapter_id); +fwprintf (stdout,L"%ls\t%ls\t%ls\n" , adapter_id, final_name, szHwId ? szHwId :L"" );CoTaskMemFree (adapter_id); } +free (final_name); + +if (result !=0 && delete_created_adapter) + { +tap_delete_adapter (NULL , &guidAdapter, bRebootRequired); + } +return result; }
@@ -327,10 +341,11 @@ {LPOLESTR adapter_id =NULL ;StringFromIID ((REFIID )&adapter->guid, &adapter_id); -fwprintf (stdout, -L"%ls\t%" -L"ls\n" , - adapter_id, adapter->szName); +const WCHAR *name = adapter->szName ? adapter->szName :L"" ; +const WCHAR *hwid = (adapter->szzHardwareIDs && adapter->szzHardwareIDs[0 ]) + ? adapter->szzHardwareIDs + :L"" ; +fwprintf (stdout,L"%ls\t%ls\t%ls\n" , adapter_id, name, hwid);CoTaskMemFree (adapter_id); }
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1372?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Iac6bcf8b5434aa414e86cb4b9742e7dd591dc796
Gerrit-Change-Number: 1372
Gerrit-PatchSet: 3
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>